//
//  VisitorViewController.swift
//  SinaWeiBo
//
//  Created by dengchen on 15/11/8.
//  Copyright (c) 2015年 name. All rights reserved.
//

import UIKit
import AFNetworking

class VisitorViewController: UITableViewController,ViesitorViewDelegate {

    override func loadView() {
        
      UserAccountOAuthModel.shared.userlogin ? super.loadView() : setupViesitorView() //如果用户未登录则显示ViesitorView,否则调用
                                                            //super.loadView()方法加载UITableViewController自带的tableView
    }
    
    let Viesitor = ViesitorView()
    
    private func setupViesitorView() {
        
        Viesitor.ViesitorDelegate = self
        
        view = Viesitor
        view.backgroundColor = UIColor(white: 0.93, alpha: 1)

        //添加导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "register")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "Login")
        
    }
    
    func Login() {
        
        let OAuth = OAuthViewController()
        
        let nav = baseNavigationController(rootViewController: OAuth)
        
        self.presentViewController(nav, animated:false, completion:nil)
    }
    
    func register() {
        print("register")
    }
    

}
